<% title "Explore - Libraries.io" %>
<% description "Find popular and trending packages by language and keyword" %>

<h1>
  <%= fa_icon 'binoculars' %>
  Explore
</h1>
<hr>

  <div class="row">
    <% @languages.each_with_index do |language, index| %>
      <% keywords = Project.popular_keywords({filters: {language: [language]}}).map{|k| k['key'].downcase }.uniq.first(15) %>
      <% next if keywords.length < 5 %>
      <div class="col-sm-4 collection">
        <h3>
          <%= link_to language_path(language.downcase) do %>
            <div class="pictogram pictogram pictogram-<%= language.downcase %>"></div>
            <%= language %>
          <% end %>
        </h3>
        <ul>
          <% keywords.each do |keyword| %>
            <% next if keyword.blank? %>
            <li>
              <a href="/explore/<%= ERB::Util.url_encode(language.downcase) %>-<%= keyword %>-libraries">
                <%= keyword %> packages
              </a>
            </li>
          <% end %>
        </ul>
      </div>
    <% end %>
  </div>
